home *** CD-ROM | disk | FTP | other *** search
/ Amiga Developer CD 2.1 / Amiga Developer CD v2.1.iso / Reference / DevCon / Washington_1988 / DevCon88.3 / Printer / src / EpsonQ / transfer.c < prev   
Encoding:
C/C++ Source or Header  |  1992-08-27  |  3.1 KB  |  124 lines

  1. /*
  2.     Transfer routine for EpsonQ driver.
  3.     David Berezowski - October/87
  4.  
  5.   Copyright (c) 1988 Commodore-Amiga, Inc.
  6.  
  7.   Executables based on this information may be used in software
  8.   for Commodore Amiga computers.  All other rights reserved.
  9.  
  10.   This information is provided "as is"; no warranties are made.
  11.   All use is at your own risk, and no liability or responsibility is assumed.
  12. */
  13.  
  14.  
  15. #include <exec/types.h>
  16. #include "../printer/printer.h"
  17. #include "../printer/prtbase.h"
  18. #include "../printer/prtgfx.h"
  19.  
  20. Transfer(PInfo, y, ptr, colors)
  21. struct PrtInfo *PInfo;
  22. UWORD y;    /* row # */
  23. UBYTE *ptr;    /* ptr to buffer */
  24. UWORD *colors; /* indexes to color buffers */
  25. {
  26.     extern struct PrinterData *PD;
  27.     extern struct PrinterExtendedData *PED;
  28.  
  29.     static UWORD bit_table[8] = {128, 64, 32, 16, 8, 4, 2, 1};
  30.     union colorEntry *ColorInt;
  31.     UBYTE *bptr, *yptr, *mptr, *cptr, Black, Yellow, Magenta, Cyan;
  32.     UBYTE *dmatrix, dvalue, threshold;
  33.     UWORD x, width, sx, *sxptr, color, bit, x3, ymod;
  34.  
  35.     /* pre-compute */
  36.     /* printer non-specific, MUST DO FOR EVERY PRINTER */
  37.     x = PInfo->pi_xpos;
  38.     ColorInt = PInfo->pi_ColorInt;
  39.     sxptr = PInfo->pi_ScaleX;
  40.     width = PInfo->pi_width;
  41.     /* printer specific */
  42.     x3 = x * 3;
  43.     ymod = y % PED->ped_NumRows;
  44.     bit = bit_table[ymod & 7];
  45.     ptr += ymod >> 3;
  46.     bptr = ptr + colors[0];
  47.     yptr = ptr + colors[1];
  48.     mptr = ptr + colors[2];
  49.     cptr = ptr + colors[3];
  50.  
  51.     /* pre-compute threshold; are we thresholding? */
  52.     if (threshold = PInfo->pi_threshold) { /* thresholding */
  53.         dvalue = threshold ^ 15;
  54.         bptr += x3;
  55.         do { /* for all source pixels */
  56.             /* pre-compute intensity values for each component */
  57.             Black = ColorInt->colorByte[PCMBLACK];
  58.             ColorInt++;
  59.  
  60.             sx = *sxptr++;
  61.  
  62.             do { /* use this pixel 'sx' times */
  63.                 if (Black > dvalue) {
  64.                     *bptr |= bit;
  65.                 }
  66.                 bptr += 3;
  67.             } while (--sx);
  68.         } while (--width);
  69.     }
  70.     else { /* not thresholding, pre-compute ptr to dither matrix */
  71.         dmatrix = PInfo->pi_dmatrix + ((y & 3) << 2);
  72.         if (PD->pd_Preferences.PrintShade == SHADE_GREYSCALE) { 
  73.             bptr += x3;
  74.             do { /* for all source pixels */
  75.                 /* compute intensity val for each component */
  76.                 Black = ColorInt->colorByte[PCMBLACK];
  77.                 ColorInt++;
  78.  
  79.                 sx = *sxptr++;
  80.  
  81.                 do { /* use this pixel 'sx' times */
  82.                     if (Black > dmatrix[x & 3]) {
  83.                         *bptr |= bit;
  84.                     }
  85.                     x++; /* done 1 more printer pixel */
  86.                     bptr += 3;
  87.                 } while (--sx);
  88.             } while (--width);
  89.         }
  90.         else { /* color */
  91.             do { /* for all source pixels */
  92.                 /* compute intensity val for each component */
  93.                 Black = ColorInt->colorByte[PCMBLACK];
  94.                 Yellow = ColorInt->colorByte[PCMYELLOW];
  95.                 Magenta = ColorInt->colorByte[PCMMAGENTA];
  96.                 Cyan = ColorInt->colorByte[PCMCYAN];
  97.                 ColorInt++;
  98.  
  99.                 sx = *sxptr++;
  100.  
  101.                 do { /* use this pixel 'sx' times */
  102.                     dvalue = dmatrix[x & 3];
  103.                     if (Black > dvalue) {
  104.                         *(bptr + x3) |= bit;
  105.                     }
  106.                     else  { /* black not rendered */
  107.                         if (Yellow > dvalue) {
  108.                             *(yptr + x3) |= bit;
  109.                         }
  110.                         if (Magenta > dvalue) {
  111.                             *(mptr + x3) |= bit;
  112.                         }
  113.                         if (Cyan > dvalue) {
  114.                             *(cptr + x3) |= bit;
  115.                         }
  116.                     }
  117.                     x++; /* done 1 more printer pixel */
  118.                     x3 += 3;
  119.                 } while (--sx);
  120.             } while (--width);
  121.         }
  122.     }
  123. }
  124.